package com.zlx.ssm.controller;

import com.zlx.ssm.service.impl.EmpolyteServiceImpl;
import com.zlx.ssm.vo.AddUserInfo;
import com.zlx.ssm.vo.DateInfo;
import com.zlx.ssm.vo.ResultDateVo;
import lombok.extern.log4j.Log4j;
import lombok.extern.log4j.Log4j2;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@Slf4j
public class AddListUserController {

    @Autowired
    private EmpolyteServiceImpl empolyteService;


    @RequestMapping("/add/User")
    public String addUser() {

        return "addAdimnList";
    }


    @RequestMapping(value = "/add/UserInfo",method = RequestMethod.POST)
    @ResponseBody
    public ResultDateVo addUserInfo(@RequestBody DateInfo dateInfo)  {
        log.info("测试添加数据    :"+ dateInfo);

        ResultDateVo resultDateVo = new ResultDateVo();
        if ("".equals(dateInfo.getName()) && dateInfo.getName() == null) {
            resultDateVo.setCode("-1");
            resultDateVo.setMsg("账户为空");
           return resultDateVo ;
        }


        try {

            empolyteService.AddAdimn(dateInfo);
            resultDateVo.setMsg("添加成功");
            resultDateVo.setCode("0");

            return resultDateVo;

        } catch (Exception e) {
            e.printStackTrace();
            resultDateVo.setMsg("消息错误");
            resultDateVo.setCode("-1");

            return resultDateVo;
        }


    }
}
